
#import "LLSearchView.h"
#define kTextFiledFont [UIFont systemFontOfSize:14]
@implementation LLSearchView
- (instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        [self setup];
    }
    return self;
}

- (id)initWithCoder:(NSCoder *)aDecoder{
    
    if (self = [super initWithCoder:aDecoder]) {
        [self setup];
    }
    return self;
}

- (void)setup{
    
    self.placeholder = @"请输入要搜索的内容";
    self.font = kTextFiledFont;
    self.clearButtonMode = UITextFieldViewModeWhileEditing;
    self.leftView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"searchbar_searchlist_search_icon"]];
    self.leftViewMode = UITextFieldViewModeAlways;
//    self.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;

    self.background = [UIImage stretchableImageWithImage:@"searchbar_background"];
}

- (void)setLeftIconName:(NSString *)leftIconName{
    
    UIImageView *iconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:leftIconName]];
//    iconView.width = 20;
    iconView.contentMode = UIViewContentModeCenter;
    self.leftView = iconView;
    self.leftViewMode = UITextFieldViewModeAlways;
    
}

- (CGRect)leftViewRectForBounds:(CGRect)bounds{
//    CGFloat x = 10;
//    CGFloat y =
//    LLLog(@"%@", NSStringFromCGRect(bounds));
    
    return CGRectMake(5, 5, 20, 20);
}

@end
